import request from '@/utils/request'

/**
 * 请假申请API
 */
export const leaveApi = {
  /**
   * 分页查询请假申请列表
   */
  getLeaveList(params) {
    return request({
      url: '/leave/list',
      method: 'get',
      params
    })
  },

  /**
   * 根据ID查询请假申请
   */
  getLeaveById(id) {
    return request({
      url: `/leave/${id}`,
      method: 'get'
    })
  },

  /**
   * 新增请假申请
   */
  addLeave(data) {
    return request({
      url: '/leave',
      method: 'post',
      data
    })
  },

  /**
   * 更新请假申请
   */
  updateLeave(data) {
    return request({
      url: '/leave',
      method: 'put',
      data
    })
  },

  /**
   * 删除请假申请
   */
  deleteLeave(id) {
    return request({
      url: `/leave/${id}`,
      method: 'delete'
    })
  },

  /**
   * 撤销请假申请
   */
  cancelLeave(id) {
    return request({
      url: `/leave/cancel/${id}`,
      method: 'put'
    })
  },

  /**
   * 审批请假申请
   */
  approveLeave(data) {
    return request({
      url: '/leave/approve',
      method: 'put',
      data
    })
  },

  /**
   * 获取请假类型列表
   */
  getLeaveTypes() {
    return request({
      url: '/leave/types',
      method: 'get'
    })
  }
}